home *** CD-ROM | disk | FTP | other *** search
- /*------------------------------------------------------------------------------
- *
- * Apple Macintosh Developer Technical Support
- *
- * Installer 3.4 sample: Action Atoms
- *
- * File: CheckTgtSysVer.c - c Source
- *
- * by: Rich Kubota
- *
- * Copyright © 1990-1992 Apple Computer, Inc.
- * All rights reserved.
- *
- * Purpose: Sample to check that the target system is corresponds to the
- * required system version parameter passed in the aaRefCon field.
- * This code resource is used in conjunction with the installation
- * of Font Resources and the possibility that the user may select
- * a Font Installation designated for system 7.1, to be installed to
- * a target hard disk running System 7.0 or 7.0.1. As noted in the
- * script, Installer 3.4 will go ahead an create a Font folder
- * even though system 7.0 and 7.0.1 do not recognise this folder.
- * Conversely, you might also want to preflight that the user has
- * not selected a system 7.0 font installation for a system 7.1 target
- * volume
- *
- * If the target system is does not match the desired system passed in the
- * aaRefCon field, the action atom displays an alert
- * and returns the result -1, otherwise, the code returns a result of noErr.
- *
- * This action atom is designed for use by Installer 3.3 and 3.4 only as it
- * returns a longint result instead of a Boolean
- *
- *----------------------------------------------------------------------------*/
-
- #if 0
-
- C -r -b -mbg on CheckTgtSysVer.c
- Link -ra =resPurgeable -t rsrc -c RSED -rt infn=10000 ∂
- -m CHECKTGTSYSVER -sg CheckTgtSysVer ∂
- CheckTgtSysVer.c.o ∂
- "{Libraries}"Interface.o ∂
- -o CheckTgtSysVer.rsrc
-
- #endif
-
- #include <Types.h>
- #include <Quickdraw.h>
- #include <Memory.h>
- #include <Resources.h>
- #include <Files.h>
- #include <Dialogs.h>
- #include <ToolUtils.h>
- #include "ActionAtomIntf.h"
- #include "CheckTgtSysVer.h"
-
-
- /* prototypes */
- void AlertUser(short error );
-
- #pragma segment CheckTgtSysVer
- pascal long CHECKTGTSYSVER(AAPBRecPtr myAAPBPtr)
- {
- Str32 sysName[] = "\pSystem";
- short sysRefNum;
- short saveResFile;
- short **versH;
- Boolean errFlag;
-
- // check that we have been called before the installation, return noErr if not
- if (myAAPBPtr->whichStage != before)
- return (noErr);
-
- // Check that there is a blessed folder on the target volume
- if (!myAAPBPtr->blessedDirID) {
- AlertUser(kNoSystemAlert);
- return ((long)-1);
- }
-
- /* Save the current resource file chain. Even if the target system is on
- the boot volume, the live system file is now in the temporary folder
- */
-
- saveResFile = CurResFile();
-
- sysRefNum = HOpenResFile(myAAPBPtr->targetVRefNum, myAAPBPtr->blessedDirID,
- (ConstStr255Param) StripAddress((Ptr)sysName), fsRdPerm);
-
- if (sysRefNum == -1) {
- // target system file not found
- AlertUser(kNoSystemAlert);
- return ((long)-1);
- }
-
- // make sure that the tgt system file is at the head of the chain
- UseResFile(sysRefNum);
- errFlag = false; // assume no error has occured
-
- versH = (short**) Get1Resource(kversResourceType, kversResourceID);
- if (!versH) {
- // we have memory problems if the 'vers' resource can't be loaded
- AlertUser(kNoVerifyAlert);
- errFlag = true;
- }
- else {
- // now we get down to the task at hand
- if (myAAPBPtr->aaRefCon == kSys71) {
- // package for system 7.1 or greater selected
- if (**versH < kSys71) {
- // target volume has system 7.0.1 or less
- AlertUser(kSys71RequiredAlert);
- errFlag = true;
- }
- }
- else {
- // package for System 7.0.1 or earlier
- if (**versH >= kSys71) {
- // target volume has system 7.1 or greater
- AlertUser(kSys70RequiredAlert);
- errFlag = true;
- }
- }
- // we're finished with the 'vers' resource
- ReleaseResource((Handle)versH);
- }
-
- CloseResFile(sysRefNum); // finished with the target system file
-
- UseResFile(saveResFile); // restore resource chain
-
- if (errFlag)
- return (kBigBadErr);
- else
- return (noErr);
-
- }
-
- #pragma segment CheckTgtSysVer
- void AlertUser(error)
- short error;
- {
- short itemHit;
- Str255 message;
-
- /* type Str255 is an array in MPW 3 */
- GetIndString(message, kErrStrings, error);
- ParamText(message, "", "", "");
- itemHit = Alert(rUserAlert, nil);
- } /* AlertUser */
-